package huixue.cn.com.rxapp.util;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
//import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SizeReadyCallback;

import huixue.cn.com.rxapp.helper.GlideCircleTransform;

/**
 * Created by gongdongyang on 2018/7/18.
 */

public class ImageLoaderUtil {

   /* public static void loadGifImg(ImageView v, String url) {
        Glide.with(v.getContext())
                .load(url)
                .apply(new RequestOptions()
//                .asBitmap()
                        .fitCenter()
                        .diskCacheStrategy(DiskCacheStrategy.ALL))
//                .placeholder(R.drawable.head_portrait)
                .into(v);
    }

    public static void loadCircleImg(ImageView v, String url) {
        Glide.with(v.getContext())
                .load(url).apply(new RequestOptions()
                .transform(new GlideCircleTransform(v.getContext())))
//                .placeholder(R.drawable.head_portrait)
                .into(v);
    }

    public static void loadImgFillCenter(ImageView v, String localPath) {
        Glide.with(v.getContext()).load(localPath)
                .apply(new RequestOptions()
//                        .asBitmap()
                        .centerCrop()
                        .diskCacheStrategy(DiskCacheStrategy.ALL))
                .into(v);
    }

    public static void loadAdapterImg(ImageView v, String url, final View itemView) {
        Glide.with(v.getContext())
                .load(url)
                .apply(new RequestOptions()
//                        .asBitmap()
                        .centerCrop()
                        .diskCacheStrategy(DiskCacheStrategy.ALL))
//                .placeholder(R.drawable.placeholder_image)
                .into(v)
                .getSize(new SizeReadyCallback() {

                    @Override
                    public void onSizeReady(int width, int height) {

                        if (!itemView.isShown()) {
                            itemView.setVisibility(View.VISIBLE);
                        }
                    }
                });
    }*/

}
